#include <iostream>

using namespace std;

int main(){
	int num[5];
	int a,b,c,t;
	char C;
	cin>>a>>b>>c;
	if(a>b) swap(a,b);
	if(a>c) swap(a,c);
	if(b>c) swap(b,c);
	num[0]=a;
	num[1]=b;
	num[2]=c;
	cin>>C;
	cout<<num[C-'A']<<" ";
	cin>>C;
	cout<<num[C-'A']<<" ";
	cin>>C;
	cout<<num[C-'A'];
	
	return 0;
}
